/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.jm.financeiro.entity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

/**
 *
 * @author joao
 */
@Entity
@Table(name = "conta_pagar_parcela", catalog = "salao", schema = "public")
public class ContaPagarParcela implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "conta_pagar_parcela_id_parcela_seq")
    @SequenceGenerator(name = "conta_pagar_parcela_id_parcela_seq", sequenceName = "conta_pagar_parcela_id_parcela_seq", initialValue = 1, allocationSize = 1)
    @Column(name = "id_parcela", nullable = false)
    private Integer idParcela;
    @Basic(optional = false)
    @Column(name = "num_parcela", nullable = false)
    private int numParcela;
    @Basic(optional = false)
    @Column(name = "dsc_parcela", nullable = false, length = 40)
    private String dscParcela;
    @Basic(optional = false)
    @Column(name = "vlr_parcela", nullable = false, precision = 18, scale = 2)
    private BigDecimal vlrParcela;
    @Column(name = "vlr_desconto_parcela", precision = 18, scale = 2)
    private BigDecimal vlrDescontoParcela;
    @Column(name = "vlr_multa_parcela", precision = 18, scale = 2)
    private BigDecimal vlrMultaParcela;
    @Column(name = "vlr_juros", precision = 18, scale = 2)
    private BigDecimal vlrJuros;
    @Column(name = "vlr_pago", precision = 18, scale = 2)
    private BigDecimal vlrPago;
    @Column(name = "vlr_imposto", precision = 18, scale = 2)
    private BigDecimal vlrImposto;
    @Basic(optional = false)
    @Column(name = "tip_status", nullable = false, length = 1)
    private String tipStatus;
    @JoinColumn(name = "id_baixa", referencedColumnName = "id_baixa", nullable = true)
    @ManyToOne(optional = true)
    private TipoBaixa idBaixa;
    @JoinColumn(name = "id_pagamento", referencedColumnName = "id_pagamento", nullable = true)
    @ManyToOne(optional = true)
    private FormaPagamento idPagamento;
    @Basic(optional = false)
    @Column(name = "dat_vcto", nullable = false)
    @Temporal(TemporalType.DATE)
    private Date datVcto;
    @Column(name = "dat_pagto")
    @Temporal(TemporalType.DATE)
    private Date datPagto;
    /*
    @JoinColumn(name = "id_conta", referencedColumnName = "id_conta", nullable = true)
    @ManyToOne(optional = true)
    private ContaBancaria idConta;
    */
    @JoinColumn(name = "id_pagar", referencedColumnName = "id_pagar", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private ContaPagar idPagar;
    @Transient
    private String dscStatus;

    public ContaPagarParcela() {
    }

    public ContaPagarParcela(Integer idParcela) {
        this.idParcela = idParcela;
    }

    public ContaPagarParcela(Integer idParcela, int numParcela, String dscParcela, Date datVcto, BigDecimal vlrParcela, String tipStatus) {
        this.idParcela = idParcela;
        this.numParcela = numParcela;
        this.dscParcela = dscParcela;
        this.datVcto = datVcto;
        this.vlrParcela = vlrParcela;
        this.tipStatus = tipStatus;
    }

    public Integer getIdParcela() {
        return idParcela;
    }

    public void setIdParcela(Integer idParcela) {
        this.idParcela = idParcela;
    }

    public int getNumParcela() {
        return numParcela;
    }

    public void setNumParcela(int numParcela) {
        this.numParcela = numParcela;
    }

    public String getDscParcela() {
        return dscParcela;
    }

    public void setDscParcela(String dscParcela) {
        this.dscParcela = dscParcela;
    }

    public Date getDatVcto() {
        return datVcto;
    }

    public void setDatVcto(Date datVcto) {
        this.datVcto = datVcto;
    }

    public Date getDatPagto() {
        return datPagto;
    }

    public void setDatPagto(Date datPagto) {
        this.datPagto = datPagto;
    }

    public BigDecimal getVlrParcela() {
        return vlrParcela;
    }

    public void setVlrParcela(BigDecimal vlrParcela) {
        this.vlrParcela = vlrParcela;
    }

    public BigDecimal getVlrDescontoParcela() {
        return vlrDescontoParcela;
    }

    public void setVlrDescontoParcela(BigDecimal vlrDescontoParcela) {
        this.vlrDescontoParcela = vlrDescontoParcela;
    }

    public BigDecimal getVlrMultaParcela() {
        return vlrMultaParcela;
    }

    public void setVlrMultaParcela(BigDecimal vlrMultaParcela) {
        this.vlrMultaParcela = vlrMultaParcela;
    }

    public BigDecimal getVlrJuros() {
        return vlrJuros;
    }

    public void setVlrJuros(BigDecimal vlrJuros) {
        this.vlrJuros = vlrJuros;
    }

    public BigDecimal getVlrPago() {
        return vlrPago;
    }

    public void setVlrPago(BigDecimal vlrPago) {
        this.vlrPago = vlrPago;
    }

    public String getTipStatus() {
        return tipStatus;
    }

    public void setTipStatus(String tipStatus) {
        this.tipStatus = tipStatus;
    }

    public TipoBaixa getIdBaixa() {
        return idBaixa;
    }

    public void setIdBaixa(TipoBaixa idBaixa) {
        this.idBaixa = idBaixa;
    }

    public FormaPagamento getIdPagamento() {
        return idPagamento;
    }

    public void setIdPagamento(FormaPagamento idPagamento) {
        this.idPagamento = idPagamento;
    }
/*
    public ContaBancaria getIdConta() {
        return idConta;
    }

    public void setIdConta(ContaBancaria idConta) {
        this.idConta = idConta;
    }
*/
    public String getDscStatus() {
        if (this.tipStatus != null) {
            if (this.tipStatus.equals("A")) {
                this.dscStatus = "A Faturar";
            } else if (this.tipStatus.equals("P")) {
                this.dscStatus = "Faturado Pago";
            } else if (this.tipStatus.equals("V")) {
                this.dscStatus = "Vencido";
            }
        }
        return dscStatus;
    }

    public void setDscStatus(String dscStatus) {
        this.dscStatus = dscStatus;
    }

    public ContaPagar getIdPagar() {
        return idPagar;
    }

    public void setIdPagar(ContaPagar idPagar) {
        this.idPagar = idPagar;
    }

    public BigDecimal getVlrImposto() {
        return vlrImposto;
    }

    public void setVlrImposto(BigDecimal vlrImposto) {
        this.vlrImposto = vlrImposto;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idParcela != null ? idParcela.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ContaPagarParcela)) {
            return false;
        }
        ContaPagarParcela other = (ContaPagarParcela) object;
        if ((this.idParcela == null && other.idParcela != null) || (this.idParcela != null && !this.idParcela.equals(other.idParcela))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.jm.financeiro.entity.ContaPagarParcela[ idParcela=" + idParcela + " ]";
    }
}
